package com.example.obs.utils;

import com.alibaba.fastjson.JSON;

import java.util.Map;

public class JsonUtils {

    public static String obj2json(Object object) throws  Exception{
        return JSON.toJSONString(object);
    }

    public static <T> T json2obj(String json,Class<T> tClass) throws Exception{
        return JSON.parseObject(json,tClass);
    }
    public static <T>Map<String,Object> json2map(String json)throws Exception{
        return JSON.parseObject(json,Map.class);
    }
    public static <T> T map2obj(Map<?,?>map,Class<T> tClass)throws  Exception{
        return  JSON.parseObject(JSON.toJSONString(map),tClass);
    }

}
